package com.yequan.hbb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;

import com.yequan.hbb.R;
import com.yequan.hbb.customview.ConerImageView;
import com.yequan.hbb.entries.LearnHP;
import com.yequan.hbb.utils.CornerImageUtils;

import java.util.List;

/**
 * Created by Administrator on 2016/10/14.
 */

public class UserRecyclerAdapter  extends RecyclerView.Adapter<UserRecyclerAdapter.UserViewHolder> {

    private Context  context;

    private List<LearnHP.DataBean.CategoryBean.ItemBean>  mItemBeen;

    public UserRecyclerAdapter(Context context, List<LearnHP.DataBean.CategoryBean.ItemBean> mItemBeen) {
        this.context = context;
        this.mItemBeen = mItemBeen;
    }

    @Override
    public UserViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View inflate = LayoutInflater.from(context).inflate(R.layout.wl_l_hp_6_1, parent, false);

        return new UserViewHolder(inflate);
    }


    @Override
    public void onBindViewHolder(UserViewHolder holder, int position) {

        LearnHP.DataBean.CategoryBean.ItemBean itemBean = mItemBeen.get(position);
        CornerImageUtils.loadImage( holder.iv_content,itemBean.getImage(),R.mipmap.default_error);
        holder.iv_content.setCircle(true);

    }


    @Override
    public int getItemCount() {
        return mItemBeen.size();
    }


    public static class UserViewHolder extends RecyclerView.ViewHolder{

        private final ConerImageView iv_content;

        public UserViewHolder(View itemView) {
            super(itemView);
            iv_content = ((ConerImageView) itemView.findViewById(R.id.iv_content));
        }
    }
}
